package com.ruoyi.customer.api;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.customer.api.domain.CustomerManagement;
import com.ruoyi.customer.api.domain.WxLoginBody;
import com.ruoyi.customer.api.factory.RemoteCustomerFallbackFactory;
import com.ruoyi.system.api.domain.ShippingAddress;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;


@FeignClient(contextId = "remoteCustomerService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteCustomerFallbackFactory.class)
public interface RemoteCustomerService {
    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/management/register")
    R<Boolean> registerCustomerInfo(@RequestBody CustomerManagement sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
    /**
     * 通过用户账号查询用户信息
     *
     * @param account 账号
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/management/info/{account}")
    R<LoginUser> getCustomerInfo(@PathVariable("account") String account, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户账号查询用户信息
     *
     * @param wxLoginBody 微信登陆信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/management/infoByOpenId")
    R<LoginUser> getCustomerInfoByOpenId(@RequestBody WxLoginBody wxLoginBody, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 记录用户登录IP地址和登录时间
     *
     * @param customerManagement 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PutMapping("/management/recordlogin")
    R<Boolean> recordCustomerLogin(@RequestBody CustomerManagement customerManagement, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping(value = "/shippingAddress/getAddressInfo/{id}")
    R<ShippingAddress> getAddressInfo(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping(value = "/management/getInfoByPhoneNumber/{phoneNumber}")
    R<CustomerManagement> getInfoByPhoneNumber(@PathVariable("phoneNumber") String phoneNumber, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping(value = "/management/getInfoById/{id}")
    R<CustomerManagement> getInfoById(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
